import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import LinearLocator
from matplotlib.pyplot import MultipleLocator
import matplotlib.ticker as ticker
fig, ax = plt.subplots(subplot_kw={"projection": "3d"},figsize=(8, 5))

# Make data.
X = np.arange(0, 5, 1)
Y = np.arange(0, 5, 1)
# print(X,'\n',Y,'\n')
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)
li_X=[2,3,4,5,6,7,8,9,10]
li_Y=[1,2,3,4,5,6,7,8,9,10]
#q=3
Z_q_1=[-0.2625,-0.2290,-0.1865,-0.1481,-0.1168,-0.0924,-0.0736,-0.0590,-0.0477]
#q=2
Z_q_2=[-0.2625,-0.2290,-0.1865,-0.1481,-0.1168,-0.0924,-0.0736,-0.0590,-0.0477]
z_o=[-0.2290 ,-0.2270,-0.2269,-0.2269,-0.2268,-0.2266,-0.2263,-0.2260,-0.2256,-0.2252]


li3 = [[-0.02386906396874998, 0.755770521112178, -0.053917654786754005, -0.0036360276480000148, -0.39291258544128],
           [0.45471213599167787, 0.167644792485625, -0.11191452864074997, -0.12808724735726595, -0.705328905686125],
           [-0.471508586764984, -0.13494840814902603, -0.259925952766329, 0.382493613993634, 0.5293814338602819],
           [-0.08359642452787201, -0.08099105757195202, 0.36077961664049807, -0.118141841729106, -0.04767854593041401]]

'''
data_X=np.array([np.array(li_X) for i in range(2)])
data_Y=np.array([np.array([(j+1) for _ in range(9)]) for j in range(2)])
data_Z=np.array([np.array(Z_q_1),np.array(Z_q_2)])
print(data_X,'\n',data_Y,'\n',data_Z,'\n')
'''
li=[2,3,4,5,6]
data_X=np.array([np.array(li) for i in range(4)])
data_Y=np.array([np.array([(j+1) for _ in range(5)]) for j in range(4)])
data_Z=np.array([np.array(li3[i]) for i in range(4)])

print(data_X,'\n',data_Y,'\n',data_Z,'\n')

# Plot the surface.
# surf = ax.plot_surface(X, Y, Z, cmap=plt.get_cmap('rainbow'),linewidth=0, antialiased=False)

# Plot the surface.
surf = ax.plot_surface(data_X, data_Y, data_Z, cmap=plt.get_cmap('rainbow'),linewidth=0, antialiased=True)
# Customize the z axis.
ax.set_zlim(-1.01, 1.01)
ax.zaxis.set_major_locator(LinearLocator(10))
# A StrMethodFormatter is used automatically
ax.zaxis.set_major_formatter('{x:.1f}')

ax.xaxis.set_major_locator(mpl.ticker.FixedLocator([2,3,4,5,6]))
ax.yaxis.set_major_locator(mpl.ticker.FixedLocator([1,2]))

# y_major_locator=MultipleLocator(1)
# ax.yaxis.set_major_formatter('{x:5.2f}')

# Add a color bar which maps values to colors.
fig.colorbar(surf, shrink=0.5, aspect=5)

plt.show()
